<script setup lang="ts">
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import updateApp from "./utils/updateApp";
import { onLoad } from "@dcloudio/uni-app";
import { toast } from "@/utils/tools";
// #ifdef MP-WEIXIN
import { login } from "./utils/auth";
// #endif

onLaunch(() => {
  // #ifdef MP-WEIXIN
  updateApp();
  login();
  // #endif
});

onLoad(() => { });
onShow((res: any) => {
  if (res.referrerInfo.extraData) {
    if (!uni.getStorageSync('isPaySuccess')) {
      return
    }
    let payStatus = res.referrerInfo.extraData.payStatus
    // 用户点击【返回】按钮时可以收到的通知参数
    if (payStatus === '1') {
      // 支付成功
      setTimeout(() => {
        uni.setStorageSync('currentIndex', null)
        uni.removeStorageSync('couponId');
        uni.removeStorageSync('couponMoney');
        uni.navigateBack()
      }, 1000)
      // toast('支付成功');
    }
    else {
      // 未知。。
      if (payStatus === '1') {
        toast('支付失败');
      } else if (payStatus === '3') {
        toast('用户取消支付');
      }
    }
    uni.removeStorageSync('isPaySuccess');
  }
});
onHide(() => {
});
</script>

<style lang="scss">
// 字体图标
// 动画库
@import "@/styles/animate.css";
@import "@climblee/uv-ui/index.scss";
@import "@/styles/common.scss";

:root {
  --animate-duration: 1s;
  --animate-delay: 1s;
  --animate-repeat: 1;
}

button {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  box-shadow: none;
  outline: none;
}

button:after {
  content: none;
  border: none;
}

.crosswise {
  display: flex;
  align-items: center;
}

.crosswise-sp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.crosswise-sp-noc {
  display: flex;
  justify-content: space-between;
}

.vertical {
  display: flex;
  flex-direction: column;
}

.vertical-sp {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.flex-box-display {
  display: flex;
  align-items: center;
  justify-content: center;
}

.two-row {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.row-box {
  padding: 30rpx 24rpx;
  border-radius: 20rpx;
  background-color: rgba(255, 255, 255, 1);
  box-shadow: 2rpx 2rpx 8rpx 0rpx rgba(0, 0, 0, 0.1);
  border: 0rpx solid rgba(187, 187, 187, 1);
}

.btn-box {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  padding: 10px 15px 20px;
  box-sizing: border-box;
  background-color: rgba(255, 255, 255, 1);
  box-shadow: 0rpx -4rpx 4rpx 0rpx rgba(0, 0, 0, 0.1);
  border: 0rpx solid rgba(187, 187, 187, 1);

  button {
    height: 40px;
    border-radius: 40rpx;
    background: linear-gradient(89.54deg,
        rgba(191, 1, 3, 1) 0.69%,
        rgba(255, 84, 2, 1) 99.31%);
    color: rgba(255, 255, 255, 1);
    font-size: 28rpx;
    border: 0rpx solid rgba(187, 187, 187, 1);
  }
}
</style>
